#include <iostream>
#include <string>
#include <fstream>
#include "interface.h"
#include "windows.h"
#include "stdio.h"
#include "conio.h"

using namespace std;

void setcolor(short color)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
	return;
}

short blink(short *color)
{
	if((*color)==0)
		(*color)=1;
	else
		(*color)=0;

	return ((*color)+7);
}

void gotoxy ( short x, short y )
{
  COORD coord = {x, y};
  SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), coord );
}

void writeline(string tekst, short y, int active)
{
	int dlugosc = tekst.length();
	short x;
	x=((X_-dlugosc)/2);
	gotoxy(x,y);
	if(active)
setcolor(10);
	else
setcolor(2);
	cout<<tekst;
	
}

void writetab(string tablica[], int ilosc, int active, char filename[])
{
	int current=0;
	int y=int((Y_-ilosc)/2);
	for(int i=0;i<ilosc;i++)
	{
		if(active==i) 
			current=1;
		else
			current=0;
		writeline(tablica[i],y++, current);
	}
	gotoxy(0,Y_);
	cout<<"Loaded file: "<<filename;
}

char getkey()
{

char key;
	while(!(_kbhit())){Sleep(10);}; //Sleep, zeby program nie zabieral duzo zasobow procesora
	key = _getch();
	if((key <= '\0'))
	{
	key = _getch();
	}

	return key;
}

